package com.ruoyi.config;

import com.ruoyi.utils.file.FileUploadUtils;
import jakarta.annotation.PostConstruct;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * 读取项目相关配置
 *
 * 
 */
@Slf4j
@Getter
@Setter
@Configuration(proxyBeanMethods = false)
@ConfigurationProperties(prefix = "ruoyi")
public class RuoYiConfig {

    public static String PROFILE;// 上传路径
    public static boolean ADDRESS_ENABLED;// 获取地址开关
    public static String CAPTCHA_TYPE;// 验证码类型


    /**
     * 项目名称
     */
    private String name;

    /**
     * 版本
     */
    private String version;

    /**
     * 版权年份
     */
    private String copyrightYear;
    /**
     * 上传路径
     */
    public String profile;

    /**
     * 获取地址开关
     */
    public Boolean addressEnabled;

    /**
     * 验证码类型
     */
    public String captchaType;


    @PostConstruct
    public void init() {
        log.info("初始化数据。。。 RuoYiConfig#init ");
        RuoYiConfig.PROFILE = getProfile();
        RuoYiConfig.ADDRESS_ENABLED = getAddressEnabled();
        RuoYiConfig.CAPTCHA_TYPE = getCaptchaType();
        FileUploadUtils.defaultBaseDir = RuoYiConfig.PROFILE;
    }


    public static String getImportPath() {
        return RuoYiConfig.PROFILE + "/import";
    }

    public static String getAvatarPath() {
        return RuoYiConfig.PROFILE + "/avatar";
    }

    public static String getDownloadPath() {
        return RuoYiConfig.PROFILE + "/download/";
    }

    public static String getUploadPath() {
        return RuoYiConfig.PROFILE + "/upload";
    }
}
